package com.listener;

import java.util.ArrayList;
import java.util.List;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

public class MyListener implements TaskListener {
	private static int a=0;
	public void notify(DelegateTask delegateTask) {
		// 获取事件名称
		String eventName = delegateTask.getEventName();
		// 获取任务id
		String taskId = delegateTask.getId();
		// 获取节点键
		String taskKey = delegateTask.getTaskDefinitionKey(); //userTask3
		// 获取流程定义编号
		String procDefId = delegateTask.getProcessDefinitionId();
		// 获取流程实例编号
		String procInstId = delegateTask.getProcessInstanceId();

		// 获取节点名称
		List<String> list = (ArrayList<String>)delegateTask.getVariable("assigneeList");
		
			if ("create".equals(eventName)) {
				//初始化会签人员信息
				//初始化业务规则
			} else if ("complete".equals(eventName)) {
				//执行业务规则
				if(delegateTask.getAssignee().toString().trim().equals("zhangsan")){
					delegateTask.setVariable("result", 1);
				}
				else
				{
					delegateTask.setVariable("result", 2);
				}
				if(delegateTask.getAssignee().toString().trim().equals("lisi")){
					delegateTask.setVariable("result", 1);
				}
				else
				{
					delegateTask.setVariable("result", 2);
				}
				if(delegateTask.getAssignee().toString().trim().equals("libo")){
					delegateTask.setVariable("result", 1);
				}
				else
				{
					delegateTask.setVariable("result", 2);
				}
				if(delegateTask.getAssignee().toString().trim().equals("xiao")){
					delegateTask.setVariable("result", 1);
				}
				else
				{
					delegateTask.setVariable("result", 2);
				}
				if(delegateTask.getAssignee().toString().trim().equals("haha")){
					delegateTask.setVariable("result", 1);
				}
				else
				{
					delegateTask.setVariable("result", 2);
				}
				if(delegateTask.getAssignee().toString().trim().equals("yunsi")){
					delegateTask.setVariable("result", 1);
				}
				else
				{
					delegateTask.setVariable("result", 2);
				}
			}
	}


}
